package com.dukun.mybatis.controller;

import com.dukun.mybatis.common.vo.AjaxResult;
import com.dukun.mybatis.entity.Grade;
import com.dukun.mybatis.enums.GradeEnum;
import com.dukun.mybatis.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Grade 控制层
 *
 * author：dukun
 * date：2021/10/20
 */
@RestController
@RequestMapping("/grade")
public class GradeController {

    @Autowired
    private GradeService gradeService;

    @GetMapping
    public AjaxResult getAllGrade() {
        List<Grade> list = gradeService.list();
        return AjaxResult.success(list);
    }

    @PostMapping
    public AjaxResult saveGrade(@RequestBody Grade grade) {
        if (gradeService.save(grade)) {
            return AjaxResult.success("保存成功！");
        }
        return AjaxResult.success("保存失败！");
    }

}
